/*smart checkbox */
function task_check( obj ){
	var name = obj.name, value = obj.value;
	if( name == 'users[]' ){
		$('input[name=user_views\\[\\]]').each(function(){
			if( this.value == value ){
				this.disabled = obj.checked;
			}
		});
	}
	if( name == 'user_views[]' ){
		$('input[name=users\\[\\]]').each(function(){
			if( this.value == value ){
				this.disabled = obj.checked;
			}
		});
	}
}

function task_check_all(elem){
	$(elem.parentNode.parentNode)
		.find("input[type=checkbox]")
		.set("checked", elem.checked )
		.each(function(){
			if( !this.disabled )
				task_check(this)
		});
}
	
/* load a action normally*/
function task_comment( form ){
	var iframe = false;
	for( var x in form.elements.length ){
		if( form.elements[x].tagName =="INPUT" && form.elements[x].type=="file" && form.elements[x].value !="" ){
			iframe =true;
			break
		}
	}
	
	iframe = true;
	if( !iframe ){
		$(form).submitAjax({
			cache: false,
			create: ajax_show,
			complete: ajax_hide,
			success: function( text ){
				$("#main-content").htm( text );
			}
		});	
		return false;
	}else{
		if( !form.iframe ){
			var name = 'a'+(new Date()).getTime();
			form.iframe = $("<iframe name='"+name+"' src='' style='display:none'></iframe>").appendTo("body").k(0);
			form.setAttribute('target',name);
		}
		
		$(form.iframe).onLoad(function(){
			var doc = this.contentWindow ? this.contentWindow.document : this.contentDocument;
			$("#main-content").htm( $( doc ).find("body").htm() );
			$("#task_quick_comment").remove();
			try{
				$('#task-last-comment').k(0).scrollIntoView(true);
			}catch(e){}	
		});	
		
		return true;
	}	
}















